#ifndef TWCORE_INTERNAL_URLSHORTENER_H
#define TWCORE_INTERNAL_URLSHORTENER_H

#include <QNetworkAccessManager>
#include <QObject>
#include <QList>
#include <QMap>
class QNetworkReply;
namespace TWCore
{
	class UrlShortenerImplementation;
	class UrlShortener : public QObject
	{
		Q_OBJECT
		public:
			UrlShortener(const QString& serviceName,QObject* parent);
			~UrlShortener();

			static QStringList getServices();

			bool urlShouldBeShorten(const QString&);
			void shorten(const QString&);
			void setService(const QString&);
		signals:
			void urlShortened(const QString&,const QString&,bool allFinished);
			void urlShortenFailed(const QString&);
		private:
			void shortenNext();
		private slots:
			void networkFinished();
		private:
			QNetworkReply*	m_reply;
			QList<QString>	m_shortenQueue;
			QString s_shorteningUrl;
			QString s_serviceName;

			QNetworkAccessManager	m_manager;
			UrlShortenerImplementation* m_impl;
	};
}
#endif // TWCORE_INTERNAL_URLSHORTENER_H
